using UnityEngine;

public class TankArrowsController : MonoBehaviour
{
	public TankArrows tankArrowsFront;

	public TankArrows tankArrowsBack;

	public GameObject tankArrowsSides;

	public RCC_CarControllerV3 carController;

	public void Init()
	{
		tankArrowsFront.gameObject.SetActive(false);
		tankArrowsBack.gameObject.SetActive(false);
		tankArrowsSides.SetActive(false);
		tankArrowsFront.Init(carController, true);
		tankArrowsBack.Init(carController, false);
	}

	private void Update()
	{
		if (carController == null || !carController.carBehaiver.isMine || carController.carBehaiver.isFree)
		{
			tankArrowsFront.gameObject.SetActive(false);
			tankArrowsBack.gameObject.SetActive(false);
			tankArrowsSides.SetActive(false);
		}
		else if (carController.gasInput > 0f || carController.brakeInput > 0f || (carController.tankTurnInput != 0f && carController.speed > 15f))
		{
			if (carController.gasInput > 0f)
			{
				tankArrowsFront.gameObject.SetActive(true);
				tankArrowsBack.gameObject.SetActive(false);
				tankArrowsSides.SetActive(false);
			}
			else if (carController.brakeInput > 0f)
			{
				tankArrowsFront.gameObject.SetActive(false);
				tankArrowsBack.gameObject.SetActive(true);
				tankArrowsSides.SetActive(false);
			}
		}
		else if (carController.tankTurnInput == 0f)
		{
			tankArrowsFront.gameObject.SetActive(false);
			tankArrowsBack.gameObject.SetActive(false);
			tankArrowsSides.SetActive(false);
		}
		else
		{
			tankArrowsFront.gameObject.SetActive(false);
			tankArrowsBack.gameObject.SetActive(false);
			tankArrowsSides.SetActive(true);
			if (carController.tankTurnInput > 0f)
			{
				tankArrowsSides.transform.localScale = Vector3.one;
			}
			else
			{
				tankArrowsSides.transform.localScale = new Vector3(-1f, 1f, 1f);
			}
		}
	}
}
